package app.util.image.action.morph
{
	import app.util.*;
	import app.util.image.*;
	import app.util.image.action.*;
	import app.util.image.calc.*;
	
	import flash.display.*;
	
	import mx.utils.*;

	public class SkeletonReconstructionAction extends SEBasedAction
	{
		private var progress:Number = 0;
		private var ret:BitmapData;
	
		public override function getDescription():String
		{
			return "Skeleton Reconstruction";
		}
		
		protected override function getFinalBitmapData():BitmapData
		{
			return this.ret;
		}
		
		protected override function processBitmapDataByStep():Number
		{
			if(this.progress == 0)
			{
				//Try to analysis the skeleton
				var cfg:ImageConfig = Mediator.getCurrentImageConfig();
				var desc:String = StringUtil.trim(cfg.actions[cfg.stateIndex - 1]);
				if(desc != 'Skeleton')
				{
					throw new Error("Not a valid skeleton image");
				}
				
				this.ret = cfg.images[cfg.stateIndex - 2];
			}
			
			this.progress += 0.08;
			return this.progress;
		}
	}
}